package com.bodu.exchange.service.impl;

import com.bodu.exchange.entity.vo.ExchangeBillTypeVo;
import com.bodu.core.entity.ParamReq;
import com.bodu.exchange.entity.request.ExchangeBillTypeRequest;
import com.bodu.exchange.mapper.ExchangeBillTypeMapper;
import com.bodu.exchange.service.ExchangeBillTypeService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
* 账单类型 Service impl
* @author Administrator
*/
@Service
public class ExchangeBillTypeServiceImpl implements ExchangeBillTypeService {

   @Resource
   private ExchangeBillTypeMapper exchangeBillTypeMapper;

   @Override
   public ExchangeBillTypeVo getModel(Long id) {
      return  exchangeBillTypeMapper.getModel(id);
   }

   @Transactional
   @Override
   public Long save(ExchangeBillTypeRequest request) {
      exchangeBillTypeMapper.save(request);
      return request.getId();
   }

   @Transactional
   @Override
   public Long update(ExchangeBillTypeRequest exchangeBillTypeRequest) {
      exchangeBillTypeMapper.update(exchangeBillTypeRequest);
      return exchangeBillTypeRequest.getId();
   }

   @Override
   public List<ExchangeBillTypeVo> listPage(ParamReq<ExchangeBillTypeRequest> params) {
      params.setStartIndex((params.getCurrent() -1 ) * params.getSize());
      return exchangeBillTypeMapper.listPage(params);
   }

   @Override
   public Integer countPage(ParamReq<ExchangeBillTypeRequest> params) {
       return exchangeBillTypeMapper.countPage(params);
   }

   @Override
   public Integer updateDelFlagById(Long id, Integer delFlag) {
       return exchangeBillTypeMapper.updateDelFlagById(id, delFlag);
   }
}
